<template>
  <div class="panel" :class="{'no-mb': noMarginBottom }">
    <div class="panel__label" :style="{width}" :class="{'is-text-right': isTextRight}">{{ props.label }}</div>
    <div class="panel__item" :style="{'width': `calc(100% - ${width})`}">
      <slot></slot>
    </div>
  </div>
</template>
<script lang="ts" setup>
defineOptions({
  name: 'CheckBoxGroup'
});
const props = defineProps({
  label: {
    type: String,
    default: '',
    required: true
  },
  width: {
    type: String,
    default: '56px'
  },
  noMarginBottom: { // 是否需要底部边距
    type: Boolean,
    default: false
  },
  isTextRight: { // 是否label文字居右
    type: Boolean,
    default: false
  }
});
</script>
<style lang="scss" scoped>
.panel {
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;

  // align-items: center;
  width: 100%;
  margin-bottom: $baseMarginBottom;
  font-size: 14px;
  font-style: normal;
  font-weight: 500;
  line-height: 32px;
  letter-spacing: -.01px;

  &__item {
    flex: 1;
  }

  .panel,
  &__item {
    box-sizing: border-box;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
  }

  .panel {
    width: auto;

    // margin-bottom: 12px;

    &__item {
      margin-right: 12px;
    }
  }

  &.no-mb {
    margin-bottom: 0;
  }

  &__label {
    flex-shrink: 0;
    margin-right: 12px;

    &.is-text-right {
      text-align: right;
    }
  }

}
</style>
